package org.pangu.test.listener;

import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

/**
 * @author zhangyj
 * @date 2022/7/13 23:32
 */
public class ListenerSupport {
    private List<Listener> listenerList = new CopyOnWriteArrayList<>();

    public void addListener(Listener listener) {
        listenerList.add(listener);
    }

    public void triggerEvent(Event event) {
        for (Listener listener : listenerList) {
            listener.onEvent(event);
        }
    }
}
